<template>
	<view>
		<image src="/static/images/work1.jpg" mode="" class="img_bg"></image>
		<view class="" style="position: absolute; top: 0; width: 100%;">
			<view class="border-bottom bg_white">
				<view class=" display justify-between align-center">
					<view class="text-36 padding-t30 padding-b30">巡检状态</view>
					<view class="display justify-between align-center padding-r30" style="color: #ff0000;">异常</view>
				</view>
			</view>
			<view class="border-bottom bg_white margin-t30 " style="">
				<view class="display justify-between align-center">
					<view class="text-36 padding-t30 padding-b30">现场照片</view>
				</view>
				<view class="display align-center padding-b30" >
					<image :src="phone" class="addImage padding-r10" v-if="phone!=''"></image>
					<image src="/static/add.png" class="addImage" v-else></image>
				</view>
			</view>
			<view class="border-bottom bg_white">
				<view class="text-36 padding-t30 padding-b30">隐患部位及描述</view>
				<view class="display align-center">
					<textarea placeholder="请输入描述信息..." name="content" v-model="content" placeholder-style="color:#999;font-size:28upx;" />
					</view>
			</view>
			<view class="margin-t30" >
					<button @click="sign()" type="button" class="loginButton" :disabled= "disable_check">提交</button>
				</view>
				</view>
	</view>
</template>

<script >
	export default {
		data() {
			return {
				phone:'',
				content:'',
				disable_check:false,
				uid:'',
				token:'',
			}
		},
		onLoad:function(options){
			// console.log(options)
			this.phone=options.phone
			this.uid=uni.getStorageSync('user').uid;
			this.token =uni.getStorageSync('user').token;
		},
		
		methods: {
			async sign(e){
				var that=this
				// console.log(this.content)
					// console.log('uid='+this.uid+'&token='+this.token+'&danger_id='+this.d_id+'&status='+this.current1)测试传输的数据
					if(this.phone==''){
						uni.showToast({
							title:'请重新拍摄现场照片',
							icon:'none'
						})
						uni.switchTab({
							url:"../../workspace"
						})
					}
					if(this.content==''){
						uni.showToast({
							title:'请输入描述信息...',
							icon:'none'
						})
						return false
					}
					
					const {
						data: res
					} = await this.$myRequest({
						url: '/Convenient/setInspection',
						method: 'GET',
						data: {
							uid: this.uid,
							token: this.token,
							danger_id: this.d_id,
							img:this.phone,
							remark:this.content
						}
					});
					console.log(res)
					if(res.code==200){
					that.disable_check=true
					
					uni.showToast({
						title:res.datas,
						icon:'success'
					})
					
					setTimeout(()=>{
					uni.switchTab({
						url:'../../workspace'
					})
					 },1500)
					}
					else if(res.code==400){
						uni.showToast({
							title:res.datas,
							icon:'none'
						})
						return false
					}
					
					/* uni.request({
						url:'https://aqmore.sxpz.vip/AppApi/Convenient/setInspection?uid='+this.uid+'&token='+this.token+'&danger_id='+this.d_id+'&img='+this.phone+'&remark='+this.content,
						method:'GET',
						header:{'content-type':'application/x-www-form-urlencoded'},
						success:function(res){
							if(res.data.code==200){
							that.disable_check=true
							
							uni.showToast({
								title:res.data.datas,
								icon:'success'
							})
							
							setTimeout(()=>{
							uni.switchTab({
								url:'../../workspace'
							})
							 },1500)
							}
							else if(res.data.code==400){
								uni.showToast({
									title:res.data.datas.msg,
									icon:'none'
								})
								return false
							}
						
						}
					}) */
				
			}
		}
	}
</script>

<style scoped>
	.loginButton{
			height:98upx;
			line-height: 98upx;
			background:#65caff;
			box-shadow:0 2upx 10upx 0 rgba(115, 241, 255, 0.8);
			border-radius:49upx;
			color: #fff;
			text-align: center;
			z-index: 99;
			position: relative;
		}
</style>
